{% set useJquery = true %}
{% set backLink = 'changelist'|adminUrl(section, metadata) %}
{% set pageId = 'admin-change' %}

{% extends 'base.njk' %}

{% block stylesheets %}
  <link rel="stylesheet" href="/admin-static/css/form.css" />
{% endblock %}

{% block body %}
  <div class="admin-title">
    <h3>
      {{ entity|displayName(metadata) }}
    </h3>
    <div class="admin-change__change-actions">
      {% if adminEntity.changeActions %}
        {% for action in adminEntity.changeActions %}
          <form method="POST"
            action="{{ 'changeAction'|adminUrl(section, metadata, entity) }}">
            <input type="hidden"
              name="changeActionIndex"
              value="{{ loop.index0 }}" />
            <button class="btn btn-secondary">{{ action.label }}</button>
          </form>
        {% endfor %}
      {% endif %}
    </div>
  </div>
  <div class="admin-content">
    <div class="row">
      <div class="col-12 col-xl-8">
        <div class="admin-form admin-form--change">
          <form method="POST"
            action="{{ 'change'|adminUrl(section, metadata, entity) }}"
            class="entity-form entity-form--change">
            {% asyncEach widget in adminEntity.getWidgets('change', entity) %}
            <fieldset class="entity-form__field {{ field }}">
              {% include widget.template %}
            </fieldset>
            {% endeach %}
            <button type="submit" class="btn btn-primary float-right">
              Submit
            </button>
          </form>
          <form method="POST"
            action="{{ 'delete'|adminUrl(section, metadata, entity) }}">
            <input type="submit"
              value="Delete"
              class="btn btn-danger float-left"
              onclick="return confirm('Are you sure you want to delete {{ entity|displayName(
                metadata
              ) }}?')" />
          </form>
        </div>
      </div>
    </div>
  </div>
{% endblock %}
